package com.woniuxy.controller;

import com.woniuxy.entity.Phase;
import com.woniuxy.service.GradeService;
import com.woniuxy.service.PhaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/phase")
public class PhaseController {
    @Autowired
    private PhaseService phaseService;

    @Autowired
    private GradeService gradeService;


    //查询所有阶段的信息
    @RequestMapping("/all")
    @ResponseBody
    public List<Phase> all() {
        return phaseService.all();

    }

    //查询阶段下所有年级
    @RequestMapping("/findGradesByJid")
    @ResponseBody
    public Phase findGradesByJid(int jid) {
        return phaseService.findGradesByJid(jid);
    }

    //查询指定阶段、指定年级下的所有课程
    @RequestMapping("/findSubjectsByJidAndNid")
    @ResponseBody
    public Phase findSubjectsByJidAndNid(int jid, int nid) {

        return phaseService.findByJidAndNid(jid, nid);

    }
}
